package com.example.index.controller;


import com.example.index.entity.Job;
import com.example.index.entity.JobImage;
import com.example.index.service.JobImageService;
import com.example.index.service.JobService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class JobController {

    @Resource
    JobService jobService;
    @Resource
    JobImageService jobImageService;


    @GetMapping("job")
    public String job(ModelMap modelMap) {
        Page<Job> jobs = jobService.queryByPage(new Job(), PageRequest.of(0, 1000));
        List<Job> jobList = jobs.getContent();
        System.out.println(jobList);
        modelMap.addAttribute("jobList", jobList);

        Page<JobImage> jobImages = jobImageService.queryByPage(new JobImage(), PageRequest.of(0, 1000));
        List<JobImage> jobImageList = jobImages.getContent();
        System.out.println(jobImageList);
        modelMap.addAttribute("jobImageList", jobImageList);

        return "job";
    }
}
